/**
 * Copyright (C), 2019-2019, 国际人才网
 * FileName: FaceMatchUtil
 * Author:   job012
 * Date:     2019/11/26 11:28
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package io.ent.common.utils;

import org.springframework.beans.factory.annotation.Value;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author hhs
 * @create 2019/11/26
 * @since 1.0.0
 */
public class FaceMatchUtil {
    @Value("${faceLogin.URL}")
    private static String URL;
    /**
     * 重要提示代码中所需工具类
     * FileUtil,Base64Util,HttpUtil,GsonUtils请从
     * https://ai.baidu.com/file/658A35ABAB2D404FBF903F64D47C1F72
     * https://ai.baidu.com/file/C8D81F3301E24D2892968F09AE1AD6E2
     * https://ai.baidu.com/file/544D677F5D4E4F17B4122FBD60DB82B3
     * https://ai.baidu.com/file/470B3ACCA3FE43788B5A963BF0B625F3
     * 下载
     */
    public static String faceMatch(String faceBase,String dbBase) {
        // 请求url
        String url = URL;
        List<String> images = new ArrayList<>();
        Map<String, Object> faceMap = new HashMap<>();
        Map<String, Object> dbMap = new HashMap<>();
        faceMap.put("image",faceBase);
        faceMap.put("image_type","BASE64");
        dbMap.put("image",dbBase);
        dbMap.put("image_type","BASE64");
        try {

            String param = GsonUtils.toJson(images);

            // 注意这里仅为了简化编码每一次请求都去获取access_token，线上环境access_token有过期时间， 客户端可自行缓存，过期后重新获取。
            String accessToken = AuthUtil.getAuth();

            String result = HttpUtil.post(url, accessToken, "application/json", param);
            System.out.println(result);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        FaceMatchUtil.faceMatch("","");
    }
}
